<?php

namespace AppBundle\Controller;

use Psr\Log\LoggerInterface;
use AppBundle\Services\BaseService;

/**
 * @author yihao
 */
trait AppControllerTrait
{
    
    /**
     * @return LoggerInterface
     */
    abstract protected function getLogger();
    
    protected function logDebug($message, array $context = array())
    {
        $this->getLogger()->debug($message, $context);
    }

    protected function logInfo($message, array $context = array())
    {
        $this->getLogger()->info($message, $context);
    }

    protected function logNotice($message, array $context = array())
    {
        $this->getLogger()->notice($message, $context);
    }

    protected function logWarning($message, array $context = array())
    {
        $this->getLogger()->warning($message, $context);
    }

    protected function logError($message, array $context = array())
    {
        $this->getLogger()->error($message, $context);
    }

    protected function logCritical($message, array $context = array())
    {
        $this->getLogger()->critical($message, $context);
    }

    protected function logAlert($message, array $context = array())
    {
        $this->getLogger()->alert($message, $context);
    }

    protected function logEmergency($message, array $context = array())
    {
        $this->getLogger()->emergency($message, $context);
    }
    
//    protected function get($id)
//    {
//        $service = parent::get($id);
//
//        if ($service instanceof BaseService) {
//            $service->setLogger($this->getLogger());
//        }
//
//        return $service;
//    }
    
}
